package org.lmind.srd35.combat

import org.lmind.srd35.core._

trait CombatUnit extends Creature with EnvironmentUnit {
  
  def state = {
    if (hp <= -10) CombatUnitState.Dead
    else if (hp <= 1) CombatUnitState.Dying
    else if (hp == 0) CombatUnitState.Disabled
    else CombatUnitState.Normal
  }

  def distanceOf(other: Creature): Int =
    distanceOf(other.asInstanceOf[CombatUnit].position)

  def distanceOf(position: (Int, Int)): Int =
    Math.abs(position._1 - position._1) + Math.abs(position._2 - position._2)

}